﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using MediaFactory;

namespace ProjetDevExia {
    public class MediaViewCreator
    {

        private int[] margins;

        public MediaViewCreator()
        {
            this.margins = new int[] {10, 10, 10, 10};
        }

        public MediaElement getMediaView (I_Media media, double width, double height) {
            MediaElement mediaElement = new MediaElement();

            
            mediaElement.Width = width;
            mediaElement.Height = height;


            Thickness margin = mediaElement.Margin;
            margin.Top = margins[0];
            margin.Left = margins[1];
            margin.Right = margins[2];
            margin.Bottom = margins[3];
            mediaElement.Margin = margin;

            mediaElement.ScrubbingEnabled = true;
            mediaElement.LoadedBehavior = MediaState.Manual;
            mediaElement.UnloadedBehavior = MediaState.Close;

            mediaElement.Source = new Uri( media.Path);
            return mediaElement;
        }

    }
}
